package SSF.OS.NetFlow.Filter;

/**
 * Decoder base class for all kinds of data records connected using monitors.
 */
public abstract class Decoder
{
    public final static int FIELD_NOT_FOUND = -1;

    public final static byte INT_TYPE=(byte)0;
    public final static byte SHORT_TYPE=(byte)1;
    public final static byte BYTE_TYPE=(byte)2;
    public final static byte FLOAT_TYPE=(byte)3;
    public final static byte STRING_TYPE=(byte)4;
    public final static byte IP_TYPE=(byte)5;
    public final static byte LONG_TYPE=(byte)6;
    //public final static byte DOUBLE_TYPE=(byte)7;
    
    /**
     * The fieldType is also passed in so that the decoder can check
     * whether the fieldType matches the one that is retrieved by fieldName.
     * @ret the index of the field, if not exist, return FIELD_NOT_FOUND
     */
    public abstract int getFieldIndex(String fieldName, byte fieldType);

    /**
     * report the mismatch of fieldTyps and the type of requested field.
     */
    protected void reportMismatch(String fieldName, byte fieldType)
    {
	System.err.println("Type mismatch Warning: "+fieldName + " is not of type " + fieldType); 
    }
}
